# © 2024 匡科涵

# 打包指令pyinstaller --onefile --add-data "Assets/*;./Assets/" -w -i favicon.ico --version-file statement.txt ConsecutiveChess.py

from DEFlib import *
import ColorLib
import pygame
import time
import sys
import random
import math
import os

verson = "正式版 v1.943.9.Base10"
WINCOLOR = (255, 255, 255)
# 导入颜色库，初始化Pygame，设置窗口大小和标题
# 初始化全局变量
ALLCOLOR = ColorLib.AllColor()
# 窗口和棋盘的配置常量
WINDOW_SIZE = (1050, 665)
BOARD_SIZE = 30
CELL_SIZE = 20
BOARD_OFFSET = 200
# 初始化Pygame

pygame.init()

#初始化字体配置
if True:
    # 加载字体文件
    # 导入系统字体
    FONT1 = resource_path('Assets\\yhxmh.ttf')
    FONT2 = resource_path('Assets\\zhbtt.ttf')
    pygame.font.init()
    font = pygame.font.Font(FONT1, 15)
    almidfont = pygame.font.Font(FONT1, 20)
    midfont = pygame.font.Font(FONT1, 25)
    bigfont = pygame.font.Font(FONT2, 35)

logofont1 = pygame.font.Font(resource_path('Assets\\Paralines-Regular.otf'), 120)
logofont2 = pygame.font.Font(resource_path('Assets\\Paralines-Regular.otf'), 40)
logo = logofont1.render("April Maker", True, ALLCOLOR.black)
logo_rect = logo.get_rect(center=(WINDOW_SIZE[0] / 2, WINDOW_SIZE[1] / 2))
logosm = logofont2.render("From RonoWebStudio", True, ALLCOLOR.black)
logosm_rect = logosm.get_rect(center=(WINDOW_SIZE[0] / 2, WINDOW_SIZE[1] / 2 + 100))
bqtext = font.render("版权所有 2024 匡科涵", True, (0, 0, 0))
bqtext_rect = bqtext.get_rect(center=(WINDOW_SIZE[0] / 2, WINDOW_SIZE[1] / 2 + 150))

logoalpha = 255
showlogoalpha = 0

# 创建游戏窗口
win = pygame.display.set_mode(WINDOW_SIZE)
pygame.display.set_caption("ConsecutiveChess连续棋 " + verson)

logostarttime = time.time()

# 开始前的Logo页面
fastend = False
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_SPACE and not fastend:
                logoalpha = 0
                logostarttime = time.time() - 7
                fastend = True

    showlogoalpha = nonlinear_move(showlogoalpha, logoalpha, 0.5, 0.01)

    logo.set_alpha(showlogoalpha)
    logosm.set_alpha(showlogoalpha)
    bqtext.set_alpha(showlogoalpha)

    win.fill(ALLCOLOR.white)
    win.blit(logo, ((1050 - logo_rect[2])/2, (665 - logo_rect[3])/2 - 30))
    win.blit(logosm, ((1050 - logosm_rect[2])/2, (665 - logosm_rect[3])/2 + 100 - 30))
    win.blit(bqtext, ((1050 - bqtext_rect[2])/2, 10))
    pygame.display.flip()

    if time.time() - logostarttime > 5:
        logoalpha = 0
    if time.time() - logostarttime > 8:
        break

GameEndLog = 0

while True:
    import ConsecutiveChessLib
    GameEndLog = ConsecutiveChessLib.Game(win,verson,GameEndLog)
